<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ include file="/JSP/include.jsp"%>

<portlet:actionURL var="getInput">
	<portlet:param name="action" value="getInput" />
</portlet:actionURL>
<portlet:renderURL var="getServerlist">
	<portlet:param name="action" value="servicelist" />
</portlet:renderURL>

<script type="text/javascript">

	
	function toggle() {
		//var divs =   document.getElementByTagNames('div');
		var sorh = document.getElementById('usages')
		var oBtn = document.getElementById('showhide')
		
		
		if (sorh.style.display=='none') {
			sorh.style.display = 'block'
			oBtn.value='Hide Help'
		} else {
			sorh.style.display = 'none'
			oBtn.value='Show Help'
		}
	}
	
	function changeSelc(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}
	
	$(document).ready(function() { 
	    $('#usages').hide();  
	});
</script>


<div class="csp_wrap">
	<div class="csp_leftmenu"><%@ include file="/JSP/leftsidebar.jsp"%></div>
	<div class="csp_content">
	
			<h3>
				<table width="100%">
				<tr>
				<td>
				${appname}'s Submit Form
				</td>
				<td align="right">
				<a href="<portlet:renderURL>
				         <portlet:param name="action" value="servicelist"/>
				         </portlet:renderURL>" class="ui-linkButton"><span style="font: 12;">Back</span></a>
				</td>
				</tr>
				</table>
			</h3>
				 
				<form:form id="submitform" name="submitform" action="${getInput}" enctype="multipart/form-data" method="post">
				  
				  <table  class="ui-table-horizon ui-table-hoverThrough" cellPadding="5px" width="95%">
				
				  <!-- groups -->
				  <c:forEach items="${groups}" var="group" >
				   <c:if test="${group.useful}">
				   	<tr>
				  	  <th colspan="4"><b>${group.text}${group.requiredstr}</b></th>
				  	</tr>
				   </c:if>
				  	<c:choose>
				  	<c:when test = "${group.exclusive}">
						  	
						 <!--flags-->
						  <c:forEach items="${group.flag_set}" var="flag">
									<c:choose>
									<c:when test = "${flag.defaultValue}"> 
									  <tr>   
									    <th align="left"><input type="radio" name=${group.name} value=${flag.id} checked></th>
									  <td align="left" colspan="3">
											  <input type="checkbox" name=${flag.id} value=${flag.tag} checked onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${flag.id}')">
											   ${flag.text}${flag.requiredstr}
									  </td>
									  </tr>
									</c:when>
									<c:otherwise>
									  <tr>
										<th align="left" colspan="2"><input type="radio" name=${group.name} value=${flag.id} checked></th>
										<td align="left" colspan="3"> 
									   			<input type="checkbox" name=${flag.id} value=${flag.tag} onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${flag.id}')">
									   			${flag.text}${flag.requiredstr}
							   			</td>
							   		  </tr>
									</c:otherwise>
									</c:choose>
						   </c:forEach>	
						   
						  <!-- tagged -->
						   <c:forEach items ="${group.tagged_set}" var="tagged">
						   		<c:choose>
								<c:when test ="${empty tagged.values}">
						   		<!-- if values[] is empty, then the input type has to be text or file -->				
								   <c:choose>
								   <c:when test="${tagged.ptype == 'FILE'}">
								   		<c:choose>
								   		<c:when test = "${tagged.iotype == 'INPUT'}"><!-- if io type = input, then upload file -->
									  		<tr>
									  		 <th align="left"><input type="radio" name=${group.name} value=${tagged.id} checked></th>
									  		  <td align="left" colspan="2">${tagged.text}${tagged.requiredstr}</td> 
								   			  <td align="left"><input type="file" name=${tagged.tag} value="" size="15" onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${tagged.id}')"></td>
								   		    </tr>
								   		</c:when>
								   		<c:otherwise>
											  <c:choose>
											  <c:when test="${tagged.defalut == 'no default'}">
											       <tr>
									  				<th align="left"><input type="radio" name=${group.name} value=${tagged.id} checked></th>						  		
											  		<td align="left" colspan="2">${tagged.text}${tagged.requiredstr}</td>
											  		<td align="left"><input type="text" name=${tagged.tag} onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${tagged.id}')"></td>
											  	   </tr>
											  </c:when>
											  <c:otherwise>	
											       <tr>			   			 
									  				<th align="left"><input type="radio" name=${group.name} value=${tagged.id} checked></th>							  		
								   			 		<td align="left" colspan="2">${tagged.text}${tagged.requiredstr}</td> 
								   			 		<td align="left"><input type="text" name=${tagged.tag} value=${tagged.defalut} onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${tagged.id}')"></td>	
								   			 	   <tr>
								   			  </c:otherwise>	
								   			  </c:choose>						   		
								   		</c:otherwise>
								   		</c:choose>
								   </c:when>
								   
								   <c:otherwise>
								   <!-- if it is not file then it will be text -->
								   			  <c:choose>
											  <c:when test="${tagged.defalut == 'no default'}">
											      <tr>
									  				<th align="left"><input type="radio" name=${group.name} value=${tagged.id} checked></th>						  		
											  		<td align="left" colspan="2">${tagged.text}${tagged.requiredstr}</td>
											  		<td align="left"><input type="text" name=${tagged.tag}onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${tagged.id}')" ></td>
											  	  </tr>
											  </c:when>
											  <c:otherwise>
											      <tr>				   			 
									  				<th align="left"><input type="radio" name=${group.name} value=${tagged.id} checked></th>						  		
								   			 		<td align="left" colspan="2">${tagged.text}${tagged.requiredstr}</td>
								   			 		<td align="left"><input type="text" name=${tagged.tag} value=${tagged.defalut} onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${tagged.id}')"></td>
								   			 	  </tr>	
								   			  </c:otherwise>	
								   			  </c:choose>
								   </c:otherwise>
								   
								   </c:choose>
								   
								</c:when>
								
								<c:otherwise>
								<tr>
								<th align="left"><input type="radio" name=${group.name} value=${tagged.id} checked></th>	
								<td align="left" colspan="2">${tagged.text}${tagged.requiredstr}:</td>
								<!-- has value set-->
									<td align="left">
									       <c:forEach items="${tagged.values}" var="values">			       		
									       		<c:choose>
									       			<c:when test="${values == tagged.defalut}">
									       				<p><input type = "radio" name=${tagged.tag} value=${values} checked onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${tagged.id}')">${values}</p>
									       			</c:when>
									       			<c:otherwise>
									       				<p><input type = "radio" name=${tagged.tag} value=${values} onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${tagged.id}')">${values}</p>
									       			</c:otherwise>
									       		</c:choose>
									       
									       </c:forEach>
									 </td>  
								</tr>    
								</c:otherwise>
								</c:choose>
						   </c:forEach>
						   
						   <!--untagged-->
						   <c:forEach items ="${group.untagged_set}" var="untagged">
						   		<c:choose>
								<c:when test ="${empty untagged.values}">
						   		<!-- if values[] is empty, then the input type has to be text or file -->				
								   <c:choose>
								   <c:when test="${untagged.ptype == 'FILE'}">
								   		<c:choose>
								   		<c:when test = "${untagged.iotype == 'INPUT'}"><!-- if io type = input, then upload file -->
								   			<tr>
								   			<th align="left"><input type="radio" name=${group.name} id="${untagged.id}" value=${untagged.id} checked></th>
								   			<td align="left" colspan="2">${untagged.text}${untagged.requiredstr}</td>
								   			<td align="left"><input type="file" name=${untagged.id} value="" size="15" onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${untagged.id}')"></td>
								   			</tr>
								   		</c:when>
								   		<c:otherwise>
											  <c:choose>
											  <c:when test="${untagged.defalut == 'no default'}">
											       <tr>
											  		<th align="left"><input type="radio" name=${group.name} value=${untagged.id} checked></th>	
											  		<td align="left" colspan="2">${untagged.text}${untagged.requiredstr}</td>
											  		<td align="left"> <input type="text" name=${untagged.id} onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${untagged.id}')"></td>
											  	   	</tr>
											  </c:when>
											  <c:otherwise>
											       <tr>	
											  		<th align="left"><input type="radio" name=${group.name} value=${untagged.id} checked></th>				   			 
								   			 		<td align="left" colspan="2">${untagged.text}${untagged.requiredstr}</td>
								   			 		<td align="left"><input type="text" name=${untagged.id} value=${untagged.defalut} onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${untagged.id}')"></td>
								   			  	   </tr>
								   			  </c:otherwise>	
								   			  </c:choose>						   		
								   		</c:otherwise>
								   		</c:choose>
								   </c:when>
								   
								   <c:otherwise>
								   <!-- if it is not file then it will be text -->
								   			  <c:choose>
											  <c:when test="${untagged.defalut == 'no default'}">
											  		<tr>
											  		<th align="left"><input type="radio" name=${group.name} value=${untagged.id} checked></th>	
											  		<td align="left" colspan="2">${untagged.text}${untagged.requiredstr}</td>
											  		<td align="left"> <input type="text" name=${untagged.id} onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${untagged.id}')"> </td>
											  		</tr>
											  </c:when>
											  <c:otherwise>	
											  		<tr>
											  		<th align="left"><input type="radio" name=${group.name} value=${untagged.id} checked onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${untagged.id}')"></th>				   			 
								   			 		<td align="left" colspan="2">${untagged.text}${untagged.requiredstr}</td>
								   			 		<td align="left"> <input type="text" name=${untagged.id} value=${untagged.defalut} onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${untagged.id}')"></td>
								   			  		</tr>
								   			  </c:otherwise>	
								   			  </c:choose>
								   </c:otherwise>
								   
								   </c:choose>
								   
								</c:when>
								
								<c:otherwise>
								<tr>
								<th align="left"><input type="radio" name=${group.name} value=${untagged.id} checked></th>
								<td align="left" colspan="2">${untagged.text}${untagged.requiredstr}:</td>	
								<!-- has value set-->
								       <td align="left">
								       <c:forEach items="${untagged.values}" var="values">			       		
								       		<c:choose>
								       			<c:when test="${values == untagged.defalut}">
								       				<p><input type = "radio" name=${untagged.id} value=${values} checked onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${untagged.id}')">${values}</p>
								       			</c:when>
								       			<c:otherwise>
								       				<p><input type = "radio" name=${untagged.id} value=${values} onChange="changeSelc(document.forms['submitform'].elements['${group.name}'],'${untagged.id}')">${values}</p>
								       			</c:otherwise>
								       		</c:choose>
								       
								       </c:forEach>
								       </td>
								</tr>
								</c:otherwise>
								</c:choose>
						   </c:forEach>
						  
				  	</c:when>
				  	<c:otherwise>      <!-- not exc, which means no radio needed  -->
						  <!--flags-->
						  <c:forEach items="${group.flag_set}" var="flag">
									<c:choose>
									<c:when test = "${flag.defaultValue}">  
									  <tr>  
									  <td align="left"><input type="checkbox" name=${flag.id} value=${flag.tag} checked></td>
									  <td align="left" colspan="3"> ${flag.text}${flag.requiredstr}</td>
									  </tr>
									</c:when>
									<c:otherwise>
										<tr>
							   			<td align="left"><input type="checkbox" name=${flag.id} value=${flag.tag}></td>
							   			<td align="left" colspan="3"> ${flag.text}${flag.requiredstr}</td>
							   			</tr>
									</c:otherwise>
									</c:choose>
						   </c:forEach>	
						   
						  <!-- tagged -->
						   <c:forEach items ="${group.tagged_set}" var="tagged">
						   		<c:choose>
								<c:when test ="${empty tagged.values}">
						   		<!-- if values[] is empty, then the input type has to be text or file -->				
								   <c:choose>
								   <c:when test="${tagged.ptype == 'FILE'}">
								   		<c:choose>
								   		<c:when test = "${tagged.iotype == 'INPUT'}"><!-- if io type = input, then upload file -->
								   		    <tr>
								   			<td align="left" colspan="3">${tagged.text}${tagged.requiredstr}</td>
								   			<td align="left"> <input type="file" name=${tagged.tag} value="" size="20"></td>
								   			</tr>
								   		</c:when>
								   		<c:otherwise>
											  <c:choose>
											  <c:when test="${tagged.defalut == 'no default'}">
											  		<tr>
											  		<td align="left" colspan="3">${tagged.text}${tagged.requiredstr}</td>
											  		<td align="left"><input type="text" name=${tagged.tag} ></td>
											  		</tr>
											  </c:when>
											  <c:otherwise>				   			 
											  		<tr>
								   			 		<td align="left" colspan="3">${tagged.text}${tagged.requiredstr}</td>
								   			 		<td align="left"> <input type="text" name=${tagged.tag} value=${tagged.defalut}> </td>
								   			 		</tr>
								   			  </c:otherwise>	
								   			  </c:choose>						   		
								   		</c:otherwise>
								   		</c:choose>
								   </c:when>
								   
								   <c:otherwise>
								   <!-- if it is not file then it will be text -->
								   			  <c:choose>
											  <c:when test="${tagged.defalut == 'no default'}">
											        <tr>
											  		<td align="left" colspan="3">${tagged.text}${tagged.requiredstr}</td>
											  		<td align="left"> <input type="text" name=${tagged.tag}></td>
											  		</tr>
											  </c:when>
											  <c:otherwise>
											  		<tr>				   			 
								   			 		<td align="left" colspan="3">${tagged.text}${tagged.requiredstr}</td>
								   			 		<td align="left"> <input type="text" name=${tagged.tag} value=${tagged.defalut}></td>
								   			 		</tr>
								   			  </c:otherwise>	
								   			  </c:choose>
								   </c:otherwise>
								   
								   </c:choose>
								   
								</c:when>
								
								<c:otherwise>
								
								<tr>
								<td align="left" colspan="3">${tagged.text}${tagged.requiredstr}:</td>
								<td align="left">
								<!-- has value set-->
								       <c:forEach items="${tagged.values}" var="values">			       		
								       		<c:choose>
								       			<c:when test="${values == tagged.defalut}">
								       				<p><input type = "radio" name=${tagged.tag} value=${values} checked>${values}</p>
								       			</c:when>
								       			<c:otherwise>
								       				<p><input type = "radio" name=${tagged.tag} value=${values}>${values}</p>
								       			</c:otherwise>
								       		</c:choose>
								       
								       </c:forEach>
								</td>
								</tr>
								</c:otherwise>
								</c:choose>
						   </c:forEach>
						   
						   <!--untagged-->
						   <c:forEach items ="${group.untagged_set}" var="untagged">
						   		<c:choose>
								<c:when test ="${empty untagged.values}">
						   		<!-- if values[] is empty, then the input type has to be text or file -->				
								   <c:choose>
								   <c:when test="${untagged.ptype == 'FILE'}">
								   		<c:choose>
								   		<c:when test = "${untagged.iotype == 'INPUT'}"><!-- if io type = input, then upload file -->
								   			<tr>
								   			<td align="left" colspan="3">${untagged.text}${untagged.requiredstr}</td>
								   			<td align="left"><input type="file" name="${untagged.id}" value="" size="20"></td>
								   			</tr>
								   		</c:when>
								   		<c:otherwise>
											  <c:choose>
											  <c:when test="${untagged.defalut == 'no default'}">
											  		<tr>
											  		<td align="left" colspan="3">${untagged.text}${untagged.requiredstr}</td>
											  		<td align="left"> <input type="text" name=${untagged.id} ></td>
											  		</tr>
											  </c:when>
											  <c:otherwise>				   			 
								   			 		<tr>
								   			 		<td align="left" colspan="3">${untagged.text}${untagged.requiredstr}</td>
								   			 		<td align="left"> <input type="text" name=${untagged.id} value=${untagged.defalut}></td>
								   			 		</tr>
								   			  </c:otherwise>	
								   			  </c:choose>						   		
								   		</c:otherwise>
								   		</c:choose>
								   </c:when>
								   
								   <c:otherwise>
								   <!-- if it is not file then it will be text -->
								   			  <c:choose>
											  <c:when test="${untagged.defalut == 'no default'}">
											  		<tr>
											  		<td align="left" colspan="3">${untagged.text}${untagged.requiredstr}</td>
											  		<td align="left"> <input type="text" name=${untagged.id} ></td>
											  		</tr>
											  </c:when>
											  <c:otherwise>				   			 
								   			 		<tr>
								   			 		<td align="left" colspan="3">${untagged.text}${untagged.requiredstr}</td>
								   			 		<td align="left"><input type="text" name=${untagged.id} value=${untagged.defalut}> </td>
								   			 		</tr>
								   			  </c:otherwise>	
								   			  </c:choose>
								   </c:otherwise>
								   
								   </c:choose>
								   
								</c:when>
								
								<c:otherwise>
								<tr>
								<td align="left" colspan="3">${untagged.text}${untagged.requiredstr}:</td>
								<td align="left">
								<!-- has value set-->
								       <c:forEach items="${untagged.values}" var="values">			       		
								       		<c:choose>
								       			<c:when test="${values == untagged.defalut}">
								       				<p><input type = "radio" name=${untagged.id} value=${values} checked>${values}</p>
								       			</c:when>
								       			<c:otherwise>
								       				<p><input type = "radio" name=${untagged.id} value=${values}>${values}</p>
								       			</c:otherwise>
								       		</c:choose>
								       
								       </c:forEach>
								 </td>
								 </tr>
								</c:otherwise>
								</c:choose>
						   </c:forEach>
						   
						   
				  	</c:otherwise>
				  	</c:choose>
				  	
				  </c:forEach>	
				  
				  <tr>
				  <td align="center" colspan="4">
						    <input type="submit" value="Submit" name="check" 
						    	onmouseover="this.style.borderColor='#75cd02'" 
						    	onmouseout="this.style.borderColor='#dcdcdc'" 
						    	class="btn1 pbtn1" 
						    	style="border-top-color: rgb(220, 220, 220); border-right-color: rgb(220, 220, 220); border-bottom-color: rgb(220, 220, 220); border-left-color: rgb(220, 220, 220); ">
						    <input type="reset" value="Reset" name="check"
						    	onmouseover="this.style.borderColor='#f76b00'" 
						    	onmouseout="this.style.borderColor='#dcdcdc'" 
						    	class="btn2 pbtn1" 
						    	style="border-top-color: rgb(220, 220, 220); border-right-color: rgb(220, 220, 220); border-bottom-color: rgb(220, 220, 220); border-left-color: rgb(220, 220, 220); ">    
						     <input type="button" value='Show Help' onclick='toggle();' id = 'showhide'
						     		onmouseover="this.style.borderColor='#86c6f7'" 
						            onmouseout="this.style.borderColor='#dcdcdc'" 
						            class="btn3 pbtn1" 
						            style="border-top-color: rgb(220, 220, 220); border-right-color: rgb(220, 220, 220); border-bottom-color: rgb(220, 220, 220); border-left-color: rgb(220, 220, 220); ">
				  </td>
				  </tr>
				  <tr>
				  	<td colspan="4">
				  	<div id = "usages">
						<p class="manual" >${usage} </p>
					    <p class="manual" >Usage Info:
						    <c:forEach items="${infos}" var="info">
						    	<pre>${info}</pre>
						    </c:forEach>
					</div>
				  	</td>
				  </tr>
				</table>
				</form:form>
</div>
</div>

				
				
				
